package com.blockmeta.bbs.businesslibrary.launch;

import com.blockmeta.bbs.baselibrary.utils.gson.GsonUtil;
import com.blockmeta.bbs.businesslibrary.pojo.ChainBarMapping;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by author on 2018/4/28.
 */

public class chainbarmappingYMAL implements IBaseYMAL {

    @Override
    public Map<String, Object> parser(String content, String env) {
        List<ChainBarMapping> barmapping = null;
        try {
            Type type = new TypeToken<List<ChainBarMapping>>() {
            }.getType();
           barmapping = GsonUtil.buildGson().fromJson(content, type);
        } catch (Exception e) {

        }
        HashMap<String, Object> map = new HashMap<>();
        HashMap<String,Integer> mapbar = new HashMap<>();
        if (barmapping != null) {
            for (ChainBarMapping chainBar : barmapping) {
                mapbar.put(chainBar.getName().toUpperCase(), chainBar.getId());
            }
        }
        map.put("chainbarmappingYMAL",mapbar);
        return map;
    }

}
